<template>
  <Card style="height:800px">
    <header>
      <span style="vertical-align:middle">产品名称:</span>
      <Input v-model="productTypeName" placeholder="请输入产品名称" style="width: 200px" clearable></Input>
      <Button type="primary" @click="query" style="margin-left: 20px;">查询</Button>
      <Button type="primary" @click="turnPage('dkcpaddbigiview')" style="margin-left: 10px;">新增</Button>
    </header>
    <Content style="margin-top:20px;">
      <Table border :columns="productTypeColumn" :data="data1"  style="margin-top: 20px;"></Table>
    </Content>
    <div style="text-align:center;width:100%;margin:36px auto;">
      <Page :total="total2" :current="currentPage" :page-size="pageSize" show-elevator show-total @on-change="queryPage"></Page>
    </div>
  </Card>

</template>

<script>

export default {
  data () {
    return {
      productTypeName: '',
      productTypeColumn: [
        {
          title: '序号',
          type: 'index',
          width: 80,
          align: 'center'
        },
        {
          title: '描述',
          key: 'productTypeName',
          align: 'center'
        },
        {
          title: '最小贷款金额',
          key: 'minAmount',
          align: 'center'
        },
        {
          title: '最大贷款金额',
          key: 'maxAmount',
          align: 'center'
        },
        {
          title: '模式',
          key: 'patternType',
          align: 'center'
        },
        {
          title: '业务类型',
          key: 'productGroup',
          align: 'center'
        },
        {
          title: '操作',
          key: 'action',
          width: 300,
          align: 'center',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h(
                'Button',
                {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      vm.$router.push({
                        name: 'dkcpaddbigiview',
                        query: {
                          type: '2',
                          productType: params.row.productType
                        }
                      })
                    }
                  }
                },
                '查看'
              ),
              h(
                'Button',
                {
                  props: {
                    type: 'error',
                    size: 'small'
                  },
                  style: {
                    marginLeft: '15px'
                  },
                  on: {
                    click: () => {
                      vm.$router.push({
                        name: 'dkcpaddbigiview',
                        query: {
                          type: '1',
                          productType: params.row.productType
                        }
                      })
                    }
                  }
                },
                '编辑'
              )
            ])
          }
        }
      ],
      data1: [],
      total2: 0,
      currentPage: 1,
      pageSize: 10
    }
  },
  created () {
    this.$ajax = this.$util.ajax(this.$appContext.marvels_core_product)
    this.query()
    // this.$ajax = this.$util.ajax(this.$appContext.marvels_core_system);
  },
  methods: {
    query () {
      // console.log("111");
      this.currentPage = 1
      var productTypeName = this.productTypeName.trim()
      this.$ajax.post(this.$appContext.marvels_core_product + 'product/mcpt/service/searchProduct', {
        productTypeName: productTypeName,
        currentPage: this.currentPage,
        pageSize: this.pageSize
      })
        .then(re => {
          this.data1 = re.data.data.list
          this.total2 = re.data.data.total
          this.currentPage = re.data.data.pageNum
          if (re.data.code === 'error') {
            this.$alert({ title: '提示', content: re.data.data })
          }
        })
        .catch(er => { })
    },
    turnPage (path) {
      this.$router.push(path)
    },
    queryPage (n) {
      var productTypeName = this.productTypeName.trim()
      this.$ajax.post(this.$appContext.marvels_core_product + 'product/mcpt/service/searchProduct', {
        productTypeName: productTypeName,
        pageSize: this.pageSize,
        currentPage: n
      })
        .then(re => {
          this.data1 = re.data.data.list
          this.total2 = re.data.data.total
          this.currentPage = re.data.data.pageNum
          if (re.data.code === 'error') {
            this.$alert({ title: '提示', content: re.data.data })
          }
        })
        .catch(er => { })
    }
  }
}
</script>

<style lang="less">
#addbig {
  float: right;
  margin-right: 111px;
}
</style>
